﻿using AutoMapper;
using B.S.Databasic.Api.Wrter.Application.Command.Account;
using B.S.Databasic.Api.Wrter.Application.Command.Permission;
using B.S.Databasic.Domain.RBAC;

namespace B.S.Databasic.Api.Wrter
{
    /// <summary>
    /// AutoMapper映射层
    /// </summary>
    public class MyAutoMapper : Profile
    {
        public MyAutoMapper()
        {
            //新增映射
            CreateMap<AddPermissionCommand, PermissionModel>()
                .ReverseMap() //反转
                .ForMember(x => x.PermissionName, x => x.MapFrom(y => y.PermissionName))
                .ForMember(x => x.PermissionURL, x => x.MapFrom(y => y.PermissionURL));
            //修改映射
            CreateMap<UpdatePermissionCommand, PermissionModel>().ReverseMap();
            //用户新增映射
            CreateMap<AddAccountCommand, AccountModel>().ReverseMap();
            //用户修改映射
            CreateMap<UpdateAccountCommand, AccountModel>().ReverseMap();
        }
    }
}
